<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { isLoggedIn } from '@/utils/auth'

const router = useRouter()

// 应用初始化
onMounted(() => {
  // 检查登录状态，如果已登录且在登录页面，则跳转到主页
  const currentPath = router.currentRoute.value.path
  if (isLoggedIn() && (currentPath === '/login' || currentPath === '/register')) {
    router.replace('/')
  }
})
</script>

<style lang="less">
#app {
  width: 100%;
  min-height: 100vh;
  background: #f5f5f5;
}

// 全局样式重置
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji',
    'Segoe UI Emoji', 'Segoe UI Symbol';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
</style>
